import IndexModel from '@/models/newsIndex';
import GameModel from '@/models/game';
import GameService from '@/services/gameService';
import newsService from '@/services/newsService';
import { action, computed, observable } from 'mobx';

export default class GameStore {

  @observable
  imageURL: string = 'https://image.xiaokesi.com/';
  @observable
  pageSize?: number = 1;
  @observable
  pageNumber?: number = 1;
  @observable
  gameList?: Array<GameModel>;
  @observable
  newsListLoading: boolean = false;
  @observable
  newsInfo?: GameModel;
  @observable
  newsInfoLoading: boolean = false;

  @action
  async infoGame(id: any) {
    this.newsInfoLoading = true;
    this.newsInfo = (await GameService.info(id)).dataInfo;
    this.newsInfoLoading = false;
  }
  @action
  async listGame() {
    this.newsListLoading = true;
    this.gameList = (await GameService.list(this.pageNumber, this.pageSize)).dataList;
    this.newsListLoading = false;
    console.log(this.gameList);

  }
}

export const gameStore = new GameStore();
